package com.corejava.training.collections.car.pre15.immutable;
import java.util.*;

public class SchoolImmutableDemo {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// create 3 instances of SchoolImmutable 
		SchoolImmutable school1 = new SchoolImmutable("Basset", "westlake", "Main District", 5);
		SchoolImmutable school2 = new SchoolImmutable("Mosby", "fairfax", "Fairfx District", 2);
		SchoolImmutable school3 = new SchoolImmutable("Cathederal", "orlando", "City school District", 5);
	
		// add instances to the list
		List schList = new ArrayList();
		schList.add(school1);
		schList.add(school2);
		schList.add(school3);
		
		// iteate thru list, print out with jdk 1.4 style
		Iterator ite = schList.iterator();
		while(ite.hasNext()){
			SchoolImmutable si = (SchoolImmutable)ite.next();
			System.out.println("City: = " + si.getCity());
			System.out.println("School rankings: = " + si.getGreatSchoolRanking());
			System.out.println("Name: = " + si.getName());
			System.out.println("School district: = " + si.getSchoolDistric());
			System.out.println("--------------------------");
		}
		
		// add instance to the list with jdk 1.5 style
		List<SchoolImmutable> scList = new ArrayList<SchoolImmutable>();
		scList.add(school1);
		scList.add(school2);
		scList.add(school3);
	
		// iterator thru list with jdk 1.5 style and print out
		for (SchoolImmutable schoolImmutable : scList) {
			System.out.println("START JDK 1.5 STYLE");
			System.out.println("City: = " + schoolImmutable.getCity());
			System.out.println("School rankings: = " + schoolImmutable.getGreatSchoolRanking());
			System.out.println("Name: = " + schoolImmutable.getName());
			System.out.println("School district: = " + schoolImmutable.getSchoolDistric());
			System.out.println("--------------------------");
		}
		
		
		
		
	}

	
	
	
	
}//end of class
